package DesignPatterns.入门案例;

/**
 * @ClassName Dark
 * @Description: TODO
 * @Author hl
 * @Date 2021/3/22
 * @Version V1.0
 **/
 public abstract class Dark {
    FlayBeheaveior flayBeheaveior;
    QuackBeheaveior quackBeheaveior;

    public void swim() {
        System.out.println("游泳");
    }
    public void performFlay(){
        flayBeheaveior.flay();
    }
    public void performQuack(){
        quackBeheaveior.quack();
    }


}
interface QuackBeheaveior{
    public void quack();
}
interface FlayBeheaveior{
    public void flay();
}

class Quack implements QuackBeheaveior{
    @Override
    public void quack() {
        System.out.println("呱呱叫");
    }
}
class Squack implements QuackBeheaveior{
    @Override
    public void quack() {
        System.out.println("吱吱叫");
    }
}


class FlayAnable implements FlayBeheaveior{
    @Override
    public void flay() {
        System.out.println("能够飞行");
    }
}

class FlayNoWay implements FlayBeheaveior{
    @Override
    public void flay() {
        System.out.println("不能够飞行");
    }
}

class YelloDuck extends Dark{
    public YelloDuck() {
        quackBeheaveior=new Squack();
        flayBeheaveior=new FlayAnable();
    }
}
class Mallard extends Dark{
    public Mallard() {
        quackBeheaveior=new Quack();
        flayBeheaveior=new FlayAnable();
    }

}
class MiniDuckSimulator{
    public static void main(String[] args) {
        Dark mallard=new Mallard();
        mallard.performFlay();

    }
}